<?php

#################################################################
#								HTML
#################################################################

/**
 * Prompt component register as 'component/prompt' 
 * 
 * $vars['content']			Page title (String)
 */

if($_CONTEXT=='HTML'){
	
	$_CSS_STACK->push(blg_get_site_url().'component/prompt.css');
	$_JS_STACK->push(blg_get_site_url().'component/prompt.js');		

echo <<<HTML
<div class="blg_prompt_container">
	<table><tr><td>
		<div class="blg_center_prompt_container" id="id_blg_prompt_container"></div>
	</td></tr></table>
</div>
HTML;

}
#################################################################
#								JS
#################################################################
elseif($_CONTEXT=='JS'){ ?>

function blg_hide_prompt_container(){
	$('.blg_prompt_container').hide();
}

function blg_show_prompt_container(){
	$('.blg_prompt_container').show();
}

function blg_clear_prompt_container(){
	$('#id_blg_prompt_container').html('');
}

function blg_set_prompt_container(msg){
	$('#id_blg_prompt_container').html(msg);
}

function blg_confirm(msg, accept_callback, cancel_callback){
	id_accept= blg_uniqid_generator();
	id_cancel= blg_uniqid_generator();	
	
	html= '<table class="blg_center_prompt_table"><tr><td colspan="2" class="blg_prompt_confirm_message">'+msg+'</td></tr><tr><td class="blg_prompt_confirm_accept"><span id="'+id_accept+'"><?php echo blg_echo('accept')?></span></td><td class="blg_prompt_confirm_cancel"><span id="'+id_cancel+'"><?php echo blg_echo('cancel')?></span></td></tr></table>';
	blg_set_prompt_container(html);	
	
	$('#'+id_accept).bind('click', function(){
		blg_clear_prompt_container();	
		blg_hide_prompt_container();			
		eval(accept_callback);
	});
	
	$('#'+id_cancel).bind('click', function(){
		blg_clear_prompt_container();
		blg_hide_prompt_container();
		eval(cancel_callback);
	});	
	
	blg_show_prompt_container();	
}

function blg_ask(msg, yes_callback, no_callback){
	id_yes= blg_uniqid_generator();
	id_no= blg_uniqid_generator();	
	
	html= '<table class="blg_center_prompt_table"><tr><td colspan="2" class="blg_prompt_confirm_message">'+msg+'</td></tr><tr><td class="blg_prompt_confirm_accept"><span id="'+id_yes+'"><?php echo blg_echo('yes')?></span></td><td class="blg_prompt_confirm_cancel"><span id="'+id_no+'"><?php echo blg_echo('no')?></span></td></tr></table>';
	blg_set_prompt_container(html);	
	
	$('#'+id_yes).bind('click', function(){
		blg_clear_prompt_container();	
		blg_hide_prompt_container();			
		eval(yes_callback);
	});
	
	$('#'+id_no).bind('click', function(){
		blg_clear_prompt_container();
		blg_hide_prompt_container();
		eval(no_callback);
	});	
	
	blg_show_prompt_container();	
}

function blg_alert(msg, ok_callback){
	id_ok= blg_uniqid_generator();	
	
	html= '<table class="blg_center_prompt_table"><tr><td colspan="2" class="blg_prompt_confirm_message">'+msg+'</td></tr><tr><td class="blg_prompt_alert_ok"><span id="'+id_ok+'"><?php echo blg_echo('ok')?></span></td></tr></table>';
	blg_set_prompt_container(html);	
	
	$('#'+id_ok).bind('click', function(){
		blg_clear_prompt_container();	
		blg_hide_prompt_container();			
		eval(ok_callback);
	});
	
	blg_show_prompt_container();	
}

<?php }
#################################################################
#								CSS
#################################################################
elseif($_CONTEXT=='CSS'){ ?>

div.blg_prompt_container{
	background-image: url('<?php echo blg_get_site_url()?>_graphics/default/structure/shadow.png');
	display: none;	
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 30;	
}

div.blg_prompt_container table, div.blg_prompt_container table tr td{
	width: 100%;
	height: 100%;
}
div.blg_prompt_container table tr td{
	vertical-align: middle;
	text-align: center;
}

div.blg_center_prompt_container{	
	background-image: url('<?php echo blg_get_site_url()?>_graphics/default/structure/light.png');
	border: 1px solid <?php echo blg_color('white', 'white')?>;	
	color: <?php echo blg_color('white', 'white')?>;
	padding: 15px;
	border-radius: 15px;
	width: 550px;
	margin: 0 auto;
	text-align: left;
}

table.blg_center_prompt_table{
	
}

table.blg_center_prompt_table td{
	color: <?php echo blg_color('white', 'white')?>;
}

table.blg_center_prompt_table td.blg_prompt_confirm_message{ 
	text-align: justify;
	padding: 0 0 10px 0;	
}

table.blg_center_prompt_table td.blg_prompt_confirm_accept{
	text-align: right;
	padding: 0 15px 0 0;
	width: 50%;
}

table.blg_center_prompt_table td.blg_prompt_confirm_cancel{
	text-align: left;
	padding: 0 0 0 15px;
	width: 50%;	
}

table.blg_center_prompt_table td.blg_prompt_alert_ok{
	text-align: center;
	width: 100%;	
}

table.blg_center_prompt_table td.blg_prompt_confirm_accept span, 
table.blg_center_prompt_table td.blg_prompt_confirm_cancel span,
table.blg_center_prompt_table td.blg_prompt_alert_ok span{
	border: 1px solid <?php echo blg_color('grey', 'light')?>;
	border-radius: 5px;
	padding: 2px 10px;
	height: 25px;
	line-height: 25px;
	font-weight: bold;
	cursor: pointer;
}
table.blg_center_prompt_table td.blg_prompt_confirm_accept span:hover,
table.blg_center_prompt_table td.blg_prompt_confirm_cancel span:hover,
table.blg_center_prompt_table td.blg_prompt_alert_ok span:hover,{
	border: 1px solid <?php echo blg_color('white', 'white')?>;
}

<?php }
